﻿using DDD.Application;
using DotNetCore.CAP;
using GoodsModule.IntegrationEvents;
using MediatR;
using Microsoft.AspNetCore.Components.Forms;
using OrderModule.Application.Commands;
using OrderModule.IntegrationEvents;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace OrderModule.Application.IntegrationEventsHandler
{
    public class GoodsDeductStockFailIntegrationEventHandler(IMediator mediator)
        : IIntegrationEventHandler
    {
        [CapSubscribe(nameof(GoodsDeductStockFailIntegrationEvent))]
        public Task Handle(GoodsDeductStockFailIntegrationEvent @event, CancellationToken cancellationToken = default)
        {
            //throw new NotImplementedException("触发订单取消命令");
            return mediator.Send(new CancelIOrderCommand(@event.OrderId, @event.GoodsId));
        }
    }
}
